//封装通用get和post请求
const request = {
    get(url, data = {}) {
        return new Promise((resolve, reject) => {
            uni.request({
            	url:url,
							data: data.data,
							header:{
								'Content-Type': 'application/json',
								'Accept':'application/json',
							},
            	success: (response) => {
            		resolve(response.data);
            	},
            	fail: (error) => {
            		reject(error);
            	}
            })
        })
    },
    post(url, data = {}) {
			return new Promise((resolve, reject) => {
				uni.request({
					url:url,
					data: data.data,
					method: 'POST',
					header:{
						'Content-Type': 'application/json',
						'Accept':'application/json',
					},
					success: (response) => {
						resolve(response.data);
					},
					fail: (error) => {
						reject(error);
					}
				})
			})
    }
}

// 暴露出去
export default request